from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from ..config import infer_username, infer_password, infer_url, infer_port, infer_db, web_username, web_password, web_url, web_port, web_db

# infer 数据库访问地址
SQLALCHEMY_DATABASE_URL = f"mysql+pymysql://{infer_username}:{infer_password}@{infer_url}:{infer_port}/{infer_db}?charset=utf8"

# web 数据库访问地址
WEB_SQLALCHEMY_DATABASE_URL = f"mysql+pymysql://{web_username}:{web_password}@{web_url}:{web_port}/{web_db}?charset=utf8"

#启动引擎
infer_engine = create_engine(
    SQLALCHEMY_DATABASE_URL,
    pool_recycle=3600
)

web_engine = create_engine(
    WEB_SQLALCHEMY_DATABASE_URL,
    pool_recycle=3600
)

#启动会话
InferSessionLocal = sessionmaker(bind=infer_engine)
WebSessionLocal = sessionmaker(bind=web_engine)

#数据模型的基类
Base = declarative_base()

if __name__ == "__main__":
    
    pass